#include "mapitem.hpp"

MapItem::MapItem() {
	setAcceptHoverEvents(true);
}

void MapItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) {
	setToolTip("X: " + QString::number(x()) + " / Y: " + QString::number(y()));
}

void MapItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
	QMenu menu;
	QAction *adelete = menu.addAction("Supprimer");
	QAction *aselectedAction = menu.exec(event->screenPos());

	if(aselectedAction == adelete) {
		static_cast<MapView*>(scene()->views().at(0))->canSave();
		scene()->removeItem(this);
		delete this;
	}
}

